#!/usr/bin/python
# -*- coding: UTF-8 -*-

from tornado.httpclient import HTTPClient
from tornado.httpclient import HTTPRequest
import urllib

_client = HTTPClient()


def login():
    "可以登陆，无法保持连接"
    url = "http://192.168.1.194:9090/login"
    data = {
        "username": "admin",
        "password": "123456",
        "submit": "Login"
    }
    req = HTTPRequest(url, method="POST", body=urllib.urlencode(data))
    resp = _client.fetch(req)
    print(resp.body)
    url = "http://192.168.1.194:9090/customer/detail?id=7"
    resp = _client.fetch(url)
    print(resp.body)


login()
